package com.utonw.carloan.activity.mybills;

import android.view.View;
import android.widget.CompoundButton;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;

import com.utonw.carloan.R;
import com.utonw.carloan.activity.base.BaseActivity;
import com.utonw.carloan.utils.LogUtil;

/**
 * Created by SEELE on 2017/4/10.
 */

public class ShowMyBillsActivity extends BaseActivity {
    //贷前、贷后 RadioButton
    private RadioButton mLoanPre, mLoanAfter;
    //贷前贷后 RadioGroup
    private RadioGroup mMyBills;
    //下方Indicator
    private TextView mIndicatorPre, mIndicatorAfter;

    @Override
    public int setLayout() {
        return R.layout.activity_show_my_bills;
    }

    @Override
    public void initView() {
        mMyBills = (RadioGroup) findViewById(R.id.rg_my_bills);
        mLoanPre = (RadioButton) findViewById(R.id.rb_mybills_loan_pre);
        mLoanAfter = (RadioButton) findViewById(R.id.rb_mybills_loan_after);
        mIndicatorPre = (TextView) findViewById(R.id.tv_indicator_mybills_loan_pre);
        mIndicatorAfter = (TextView) findViewById(R.id.tv_indicator_mybills_loan_after);

    }

    @Override
    public void initData() {

        initRadioGroup();

    }

    private void initRadioGroup() {
        mMyBills.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                switch (checkedId) {
                    case R.id.rb_mybills_loan_pre:
                        LogUtil.d("贷前");
                        mIndicatorPre.setVisibility(View.VISIBLE);
                        mIndicatorAfter.setVisibility(View.INVISIBLE);
                        break;

                    case R.id.rb_mybills_loan_after:
                        LogUtil.d("贷后");
                        mIndicatorPre.setVisibility(View.INVISIBLE);
                        mIndicatorAfter.setVisibility(View.VISIBLE);
                        break;
                }
            }
        });

        //设置默认选中贷前
        mLoanPre.setChecked(true);

    }

    @Override
    public String setTitle() {
        return getString(R.string.show_my_bills_mybills);
    }

}
